package org.itli.jnsocket.Mapper;

import org.apache.ibatis.annotations.*;
import org.itli.jnsocket.Pojo.Supplier;
import org.itli.jnsocket.Service.SupplierService;

import java.util.List;

@Mapper
public interface SupplierMapper {

    //查询所以供应商
    @Select("SELECT id, supplier_no, supplier_name, supplier_phone, supplier_address, supplier_contact, supplier_status, order_num, remark FROM jn_wms_supplier LIMIT #{size} OFFSET #{page}")
    List<Supplier> AllSuppliers(int size,int page);

    //添加供应商
    @Insert("insert into jn_wms_supplier (supplier_no, supplier_name, supplier_phone, supplier_address, supplier_contact, supplier_status, order_num, remark, create_by,create_time,update_by,update_time,del_flag) values (#{supplier.supplier_no},#{supplier.supplier_name},#{supplier.supplier_phone},#{supplier.supplier_address},#{supplier.supplier_contact},#{supplier.supplier_status},#{supplier.order_num},#{supplier.remark},#{create_by},NOW(),#{update_by},NOW(),'0')")
    int AddSupplier(Supplier supplier,String create_by,String update_by);

    //修改供应商
    @Update("update jn_wms_supplier set supplier_no = #{supplier.supplier_no}, supplier_name = #{supplier.supplier_name}, supplier_phone = #{supplier.supplier_phone}, supplier_address = #{supplier.supplier_address},supplier_contact = #{supplier.supplier_contact},supplier_status = #{supplier.supplier_status},order_num = #{supplier.order_num},remark = #{supplier.remark},update_by = #{update_by},update_time = NOW() where id = #{supplier.id}")
    void UpdateSupplier(Supplier supplier,String update_by);

    //删除供应商
    @Delete("delete from jn_wms_supplier where id = #{id};")
    void DeleteSupplier(int id);
}
